<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btn">发送</button>
    <script>
      document.querySelector("#btn").onclick = function () {
        fetch("http://localhost:8080/login", {
          method: "get",
          headers: {
            "content-type": "application/x-www-form-urlencoded",
          },
        }) // promise 对象 .then(function(response){})
          .then(function (resp) {
            // retrun resp.json();
            return resp.text(); // promise 对象 .then(function(text){})
          })
          .then(function (text) {
            console.log(text);
          })
          .catch(function (error) {
            console.error(error);
          });
        console.log("发送成功");
      };
    </script>
  </body>
</html>
